home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / dc15 / cmdtes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.1 KB  |  61 lines

  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<dos.h>
  5. #include<direct.h>
  6. #include"para.h"
  7.  
  8. void CmdAnalyse(char *st,PARA *pa)
  9. {
  10.     char *p,pbuf[40];
  11.     unsigned int drv;
  12.     
  13.     
  14.     if((p=strchr(st,':'))!=NULL) {
  15.         pa->drive=toupper(*(p-1))-'A'+1;
  16.         st=p+1;
  17.     }else{
  18.         _dos_getdrive(&drv);
  19.         pa->drive=drv;
  20.     }
  21.     
  22.     if((p=strrchr(st,'\\'))!=NULL){
  23.         if(p==st){
  24.             strcpy(pa->path,"\\\0");
  25.             st++;
  26.         }else{
  27.             *p='\0';
  28.             strcpy(pa->path,st);
  29.             st=p+1;
  30.         }
  31.     }else{
  32.         _getcwd(pbuf,40);
  33.         strcpy(pa->path,&pbuf[2]);
  34.     }
  35.     strcpy(pa->file,st);
  36. }
  37.  
  38.  
  39. void main(int argc,char *argv[])
  40. {
  41.     
  42.     int i;
  43.     PARA inf,outf;
  44.     
  45.     if(argc!=3){
  46.         puts("パラメーターの数があいません");
  47.         exit(1);
  48.     }
  49.     CmdAnalyse(argv[1],&inf);
  50.     CmdAnalyse(argv[2],&outf);
  51.     
  52.     printf("------------inf------------\n");
  53.     printf("Drive %c  value->%d\n",inf.drive+'0',inf.drive);
  54.     printf("Path %s\n",inf.path);
  55.     printf("file %s\n",inf.file);
  56.     printf("\n------------outf-----------\n");
  57.     printf("Drive %c  value->%d\n",outf.drive+'0',outf.drive);
  58.     printf("Path %s\n",outf.path);
  59.     printf("file %s\n",outf.file);
  60. }
  61.